<!--
  @author heguanghua
  @since 2020/04/23 13:44
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss"/>
<body>

<div class="layui-fluid"
     th:with="hasPermitTree=${#authPermit.checkPermit('/role/permit/tree.action')},
     hasAddEdit=${#authPermit.checkPermit('/role/modify/addEdit.action') && isAssignAdmin},
     hasStaffList=${#authPermit.checkPermit('/role/staff/list.action')}">

    <blockquote class="layui-crumb">
        <a lay-href="/role/list.action">角色管理</a>
        &nbsp;>&nbsp;
        <zmn th:text="${(obj.roleId eq null) ? '新增角色' : obj.roleName}">新增或修改角色</zmn>
    </blockquote>

    <div class="layui-card">

        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this"><a th:lay-href="|${SYS_MCC}/role/detail.action?roleId=${obj.roleId}|" lay-text="角色信息">角色信息</a></li>
                <li th:if="${obj.roleId != null && hasPermitTree}"><a th:lay-href="|${SYS_MCC}/role/permit/tree.action?roleId=${obj.roleId}|" lay-text="权限分配">权限分配</a></li>
                <li th:if="${obj.roleId != null && hasStaffList}"><a th:lay-href="|${SYS_MCC}/role/staff/list.action?roleId=${obj.roleId}|" lay-text="授权人员">授权人员</a></li>
                <li th:if="${obj.roleId != null}"><a th:lay-href="|${SYS_MCC}/role/change/log/list.action?roleId=${obj.roleId}|" lay-text="操作记录">操作记录</a></li>
            </ul>
        </div>

        <div class="layui-card-body">

            <blockquote class="layui-elem-quote layui-quote-nm">
                1. "系统全局角色"不属于任何组织和部门，用于公司总部特殊管理人员使用，可以超出其所属部门权限范围管理使用系统，可以为部门和员工分配各种维度的数据权限。"系统全局角色"没有部门归属，只有超级管理员可创建；<br/>
                2. "部门内部角色"仅限于管理部门及其下级部门员工的功能权限，不能管理和分配数据权限。如不指定"部门内部角色"的所属部门，则默认为创建者所属部门。
            </blockquote>

            <form method="POST" action="" class="layui-form" lay-filter="zmn-form">

                <input type="hidden" name="roleId" th:value="${obj.roleId}"/>
                <input type="hidden" name="type" th:value="${obj.type}"/>

                <div class="layui-card-header layui-margin-b"><b>基本信息</b></div>

                <div class="layui-form-item layui-form-item-sm" th:if="${obj.roleId > 0}">
                    <label class="layui-form-label">角色ID：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${obj.roleId}">ID</span>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">角色名称：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="roleName" th:value="${obj.roleName}" placeholder="角色的名称" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="20"/>
                    </div>
                </div>
                <!--超级管理员才可以选择创建"系统全局角色"-->
                <div class="layui-form-item" th:if="${(obj.roleId == null || obj.roleId == 0) && isSuperAdmin}">
                    <label class="layui-form-label">角色类型：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="type" th:value="${type.key}" th:checked="${type.key eq obj.type}" th:title="${type.value}" th:each="type:${types}">&nbsp;
                    </div>
                </div>

                <!--系统全局角色才可以选择选择组织-->
                <div class="layui-form-item" th:if="${isGlobalAdmin}">
                    <label class="layui-form-label">所属组织：</label>
                    <div class="layui-input-inline">
                        <div id="plat" name="plat"></div>
                    </div>
                    <div class="layui-input-inline">
                        <div id="orgTwoId" name="orgTwoId"></div>
                    </div>
                    <div class="layui-input-inline">
                        <div id="orgId" name="orgId"></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属部门：</label>
                    <div class="layui-input-inline" th:if="${isGlobalAdmin}">
                        <div id="deptId"></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">数据导出上限：</label>
                    <div class="layui-input-inline" style="width:100px">
                        <input type="text" name="exportLimit" th:value="${obj.exportLimit}" placeholder="数量上限" lay-verify="required|exportLimit" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="7"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">最大值<th:block th:text="${exportLimit}">exportLimit</th:block>，0表示不能导出任何数据</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">查询前溯天数：</label>
                    <div class="layui-input-inline" style="width:100px">
                        <input type="text" name="dayLimit" th:value="${obj.dayLimit}" placeholder="天数上限" lay-verify="required|dayLimit" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="7"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">当日往前回溯天数，最大值<th:block th:text="${dayLimit}">dayLimit</th:block>，0表示不能查询任何数据</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">查询条数：</label>
                    <div class="layui-input-inline" style="width:100px">
                        <input type="text" name="numberLimit" th:value="${obj.numberLimit}" placeholder="查询条数上限" lay-verify="required|numberLimit" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="5"/>
                    </div>
                    <div class="layui-form-mid layui-word-aux">最大值50000条，0表示不能查询任何数据</div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">备注说明：</label>
                    <div class="layui-input-block" style="width:600px;">
                        <textarea name="remark" th:text="${obj.remark}" class="layui-textarea" placeholder="" lay-verify="" lay-verType="tips"></textarea>
                    </div>
                </div>

                <zmn th:if="${obj.roleId > 0}">
                    <div class="layui-card-header layui-margin-b"><b>其他信息</b></div>

                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">角色类型：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux" th:text="${T(com.zmn.mcc.common.constant.RoleDict).roleTypeMap().get(obj.type)}">角色类型</div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">修改人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux" th:text="${obj.updater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.updateTime, 'yyyy-MM-dd HH:mm:ss')}">修改人/时间</div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">创建人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux" th:text="${obj.creater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.createTime, 'yyyy-MM-dd HH:mm:ss')}">创建人/时间</div>
                        </div>
                    </div>
                </zmn>

                <div class="layui-form-item submit">
                    <div class="layui-input-block" th:if="${hasAddEdit}">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-form-submit">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>

            </form>

        </div>

    </div>

</div>
</body>
</html>

<style type="text/css">
    xm-select .xm-label .scroll .label-content {
        color: black !important;
    }
</style>

<script type="text/javascript" th:inline="javascript">

    var json = {
        roleId: [[${obj.roleId}]],
        isSuperAdmin: [[${isSuperAdmin}]],
        isGlobalAdmin: [[${isGlobalAdmin}]],
        orgId: [[${operator.orgId}]],
        deptId: [[${operator.deptId}]],
        deptLevel: [[${deptLevel}]],
        orgOneId: [[${orgOne.orgId}]],
        orgTwoId: [[${orgTwo.orgId}]],
        orgThrId: [[${orgThr.orgId}]],
        role: [[${obj}]],
    };

    layui.extend({
        role_detail: "role/zmn.role.detail",
    }).use(['index', 'role_detail']);
</script>
